<%--
 *  File:   zylstdbusinessarea.jsp
 *  @Author: zahirzhong
 *  Date:    2012/08/30
 *
 *  Copyright (C) 2000 - 2002 Oval Technologies, Inc.
 *  All rights reserved.
 *
 *  This software is the confidential and proprietary information of Oval
 *  Technologies, Inc. ("Confidential Information").  You shall not
 *  disclose such Confidential Information and shall use it only in
 *  accordance with the terms of the license agreement you entered into
 *  with Oval.
--%>


<%@ include file="/inc/SessionTimeout.inc"%>
<%@ page language="java" %>
<%@ page import="java.util.*" %>
<%@ page import="org.apache.log4j.Category" %>
<%@ page import="com.oval.util.*" %>

<%@ page contentType = "text/html;charset=UTF-8" %>
<%@ taglib uri="/WEB-INF/PageFlow.tld" prefix="PageFlow" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/custom.tld" prefix="custom" %>


<% //--------------------------------------  setting logger --%>


<% //--------------------------------------  variant and initialization --%>
<%
	String strModuleName = "DMS";
 	String strTableName = "v_zylstdarea";
	String privilegeCode = "10219";    
    String contextPath = request.getContextPath(); 
%>

<% //--------------------------------------  include files list --%>

<%@ include file="/inc/Security.inc" %>
<%@ include file="/inc/FrmDefault.inc" %>
<%@ include file="/inc/PageDefault.inc" %>
<%@ include file="/inc/LocationDefault.inc" %>
<%@ include file="/rpt/ReportURL.inc"%>
<html>
<head>
<title>MasterdataRelationship</title>
<PageFlow:CheckPageFlow pageName="p_zylstdarea"/>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<%@ include file="/inc/CatchError.inc" %>
<link rel="stylesheet" href="<%=contextPath %>/css/<%= strLanguageCode %>/main.css" type="text/css">
<script language="JavaScript" src="<%=contextPath %>/css/<%= strLanguageCode %>/script.js"></script>
<script language="JavaScript" src="<%=contextPath %>/js/FuncLib.js"></script>
<script language="JavaScript" src="<%=contextPath %>/js/ScriptLib.js"></script>

<%@ include file="/inc/SummaryDivision.inc" %>

<% //--------------------------------------  output variant from pageflow --%>
<%
  	Vector totalsummary = (Vector)pageContext.getAttribute("totalsummary");
	HashMap userinfo = (HashMap)session.getAttribute("userinfo");

  	if(totalsummary == null)
  	{
  		totalsummary = new Vector();
  	}
%>


<script language="JavaScript" >


var indx;
function page_summary(actionvalue,orderbyname){
	 var editform = summaryPrepare(cform,actionvalue,orderbyname);
 	 editform.action = "zylstdbusinessarea.jsp?<%= OvalTools.randomURL() %>";
 	 editform.target = "_self";
 	 isRunning = true;
 	 editform.submit();
}

function page_add(){
	 if(!checkForm(cform)) return;
	 
	 cform.actionname.value = "add";
  	 cform.target = "_self";
  	 isRunning = true;
  	 cform.submit();
}

function page_delete(){
    if(isNullChecked(cform.deleteids))
    {
        alert("<%= message.getMessageDesc("MUST_SELECT_ONE_RECORD_TO_DEL") %>");
        return;
    }
    if(!confirm("<%= message.getMessageDesc("ARE_YOU_SURE_DEL") %>")) return;
    
    cform.actionname.value = "delete";
    cform.target = "_self";
    isRunning = true;
	cform.submit();
}

function allcheckselect(){
	var allcheck = cform.allcheck.checked;
	var alldatafile = document.getElementsByName('deleteids');
	var length = alldatafile.length;
	if(allcheck){
		for(var i = 0 ; i < length;i++){
			alldatafile[i].checked = true;
		}
	}else{
		for(var i = 0 ; i < length;i++){
			alldatafile[i].checked = false;
		}	
	}
}



function page_save(){


var numrows = document.cform.numrows.value;
	for (i=0;i<numrows;i++){
	 var areanameObj= eval("document.cform.areaname"+i);
	 if (areanameObj.value ==null ||areanameObj.value==""||areanameObj.value==" ")
	 {
	 alert("<%= message.getMessageDesc("VALUE_NOT_NULL",label.getLabelName("L_AreaName"))%>");
	 return;
	 }
	 }
	cform.actionname.value = "save";
    cform.target = "_self";
    isRunning = true;
	cform.submit();
}

var index = 0;
function mathindex(com){
    if(com.checked){
    	index++;
    }else{
    	index--;
    }
}

function page_selectUser2(i) {
            indx = i;
		var status = "height=400, width=600,top=100,left=100,toolbar=no, menubar=no, scrollbars=yes, resizable=no, location=no, status=no";
		var url = "<%=contextPath%>/img/UserSelectPop.jsp?o_thread=" + Math.random()+"&flag=2";
			
		if (typeof popwindow != 'undefined') popwindow.close();
		popwindow = window.open(url, "newwindow", status);
}
function page_selectUser() {
   indx = -1;
		var status = "height=400, width=600,top=100,left=100,toolbar=no, menubar=no, scrollbars=yes, resizable=no, location=no, status=no";
		var url = "<%=contextPath%>/img/UserSelectPop.jsp?o_thread=" + Math.random()+"&flag=2";
			
		if (typeof popwindow != 'undefined') popwindow.close();
		popwindow = window.open(url, "newwindow", status);
}


function page_setUser(id,code,name){
 if (indx ==-1 ){
    
	document.cform.employeeid.value=id;

	document.cform.employeename.value=name;
	}
	else {
	eval('document.cform.employeeid'+indx).value = id;
	eval('document.cform.employeename'+indx).value = name;
	}
}

function exportExcel(){
	 window.open("<%= reportURL %>/servlet/ExcecuteReport/stdbusinessarea.sox?__format=xlsx&__folder=/ovalreport");
	}
</script>

</head>
	
<body>

<form name="cform" method="post" action="<%=contextPath %>/Dispatcher"  target="_self">
	<input type="hidden" name="pagename" value="p_zylstdarea">
	<input type="hidden" name="actionname">
	<input type="hidden" name="currentnum"/>

	<input type="hidden" name="numrows" value="<%=totalsummary.size() %>">

<% //--------------------------------------  page location --%>
	<%@ include file="/inc/PageLocation.inc" %>
	<table cellspacing="0" border="0" cellpadding="0">
	   	<tr>
	     	<td>
	
			<table cellspacing="0" border="0" cellpadding="0" onkeydown="if(event.keyCode==13) page_summary('search');">
				<tr>
		<!--				<td width="4%"><%= label.getLabelName("L_Type") + label.getLabelName("L_Colon")%>
				</td>
					<td width="8%"><custom:selectdic property ="areatypesql" dictType="ZYLAreaType" defaultValue="------" defaultValueCost="" /></td>-->
					<td width="6%"><%= label.getLabelName("L_AreaCode") + label.getLabelName("L_Colon")%></td>
					<td width="8%"><custom:text property="areacodesql" size="8"/></td>
					<td width="6%"><%= label.getLabelName("L_AreaName") + label.getLabelName("L_Colon")%></td>
					<td width="55%"><custom:text property="areanamesql" size="25"/>
<a href="javascript:page_summary('search')"><img src="<%=contextPath%>/images/<%= strLanguageCode %>/go.gif" border="0" ></a></td>
				</tr>
			</table>	
	     	</td>
	    </tr>
	    <tr> 
		    <td> 
		      <table border="1" cellpadding="0" bordercolorlight="#999999" bordercolordark="#FFFFFF" cellspacing="0" align="center">
	    	  <div style="overflow:auto;width:1000px">
		        <tr class="deepblue-left">
				  <td width="1%" class="title_center"><input type="checkbox" name="allcheck" class="normalradio" onclick="allcheckselect();"></td>
<!--		          <td class="title_center" width="8%"><a href="javascript:page_summary('orderby','areatype')"><%= label.getLabelName("L_Type") %></a>&nbsp;<span class='red'>*</span></td>-->
		          <td class="title_center" width="10%" ><a href="javascript:page_summary('orderby','areacode')"><%= label.getLabelName("L_AreaCode") %></a>&nbsp;</td>
		          <td class="title_center" width="25%" ><a href="javascript:page_summary('orderby','areaname')"><%= label.getLabelName("L_AreaName") %></a>&nbsp;<span class='red'>*</span></td>
		          <td class="title_center" width="35%"><a href="javascript:page_summary('orderby','areadesc')"><%= label.getLabelName("L_BusinessAreaDesc") %></a></td>
		          <td class="title_center" width="20%"><a href="javascript:page_summary('orderby','employeename')"><%= label.getLabelName("L_Employee") %></a></td>
		          
		          </tr>
		        <%
	            	int i = 0;
	             	String strClassType = new String();
	          	%>
		         <logic:iterate id="onerow" collection="<%= totalsummary %>" indexId="idx">
		           	<%
		            	HashMap tempMap = (HashMap)pageContext.getAttribute("onerow");
		            	if(i%2 == 1)
		            	{
		              		strClassType = "td-listrom";
		            	}else{
		              		strClassType = "";
		            	}
		            	i++;
		            	
		          	%>
		          	<tr id="tr<%=idx %>" class="none">
		          		<td id="td" class="title_center" >
		              		<input type="checkbox" name="deleteids" value="<%=JspHelper.filterNull( tempMap.get("stdareaid") )%>" class="checkbox">
		            		<custom:hidden name="onerow" property="stdareaid" colIndex="<%=idx %>"/>
		            	</td>
<!--		            	<td class="title_center">-->
<!--		            	&nbsp;<custom:write name="onerow" property="valuename" nbsp="true"/>-->
<!--		            	</td>-->
		            	<td class="title_center">
		            	&nbsp;<custom:write name="onerow" property="areacode" nbsp="true"/>
		            	</td>
		            	<td class="title_center">
		            	&nbsp;<custom:text name="onerow" property="areaname" colIndex="<%=idx %>" size="40"/>
		            	</td>
		            	<td class="title_center">
		            	&nbsp;<custom:text name="onerow" property="areadesc" colIndex="<%=idx %>"/>
		            	</td>
		            	<td class="title_center">
		            	&nbsp; <custom:text   name="onerow" property="employeename" size="12" readonly="true" colIndex="<%=idx %>"/> <a
					onclick="javascript:page_selectUser2(<%=idx %>);"><custom:button type="3" label="L_Asterisk" imgsrc="flash.gif" border="0" /></a> 
					<custom:hidden   name="onerow" property="employeeid" colIndex="<%=idx %>"/>
		            	</td>
		     		 </tr>
		     	 </logic:iterate>
		     	 <tr class="none">
		           <td>&nbsp;</td>
<!--		           <td class="title_center">-->
<!--		           <custom:selectdic property ="areatype" dictType="ZYLAreaType" defaultValue="-----"  defaultValueCost="" command="notnull" label="L_Type"/></td>-->
<!--		           -->
		           <td class="title_center">
		           	<custom:write property="areacode"  nbsp="true"/>
				   </td>
				   <td class="title_center">
		           	<custom:text property="areaname"  command="notnull" label="L_AreaName" size="40"></custom:text>
		           </td>
		           <td class="title_center">
		           	<custom:text property="areadesc" ></custom:text>
		           </td>
		           <td class="title_center">
		          <custom:text   property="employeename" size="12" readonly="true" /> <a
					onclick="javascript:page_selectUser();"><custom:button type="3" label="L_Asterisk" imgsrc="flash.gif" border="0" /></a> 
					<custom:hidden   property="employeeid" />
			     </tr>
			  </div>	
		      <%@ include file="/inc/SummaryAction.inc" %>
		      </table>	      
		      <table width="100%" cellspacing="0" cellpadding="0">
		        <tr> 
		          <td class="summary_top"></td>
		        </tr>
		        <tr>
				     <td class="td_center">
						<a onclick="page_add()"><custom:button type="1" label="L_Add" imgsrc="add.gif" border="0" style="width:60" privilegeCode="MB-BZQY01"/></a>
						<%if(totalsummary.size() >0 ){%>
						<a onclick="page_save()"><custom:button type="1" label="L_Save" imgsrc="delete.gif" border="0" style="width:60" privilegeCode="MB-BZQY02"/></a>
						<a onclick="page_delete()"><custom:button type="1" label="L_Delete" imgsrc="delete.gif" border="0" style="width:60" privilegeCode="MB-BZQY03"/></a>
						<a onclick="exportExcel();"><custom:button type="1" label="L_Execcd" imgsrc="delete.gif" border="0" style="width:60"/>
						<%} %>
					 </td>
				</tr>
		      </table>
		    </td>
	  </tr>
	
	</table>
</form>
</body>
</html>